<template>
  <router-view></router-view>
</template>
<script>
  export default {
    name: 'app',
    created () {
      // 重新获取路由
      this.setRouter()
    },
    methods: {
      // 切换页面获取重新获取路由
      setRouter () {
        let loginName = JSON.parse(sessionStorage.getItem('loginName'))
        let router = JSON.parse(sessionStorage.getItem('router'))
        if (loginName && router) {
          this.$router.addRoutes(this.shiftyRouter(router))
        } else {
          this.$router.push('/login')
        }
      }
    }
  }
</script>
